package br.unirio.octopus.visao.acoes;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.Result;

public class MyBytesResult implements Result {

	 /**
	 * 
	 */
	private static final long serialVersionUID = 5568996189333293924L;

	public void execute(ActionInvocation invocation) throws Exception {
		 
			ExibirImagemAction action = (ExibirImagemAction) invocation.getAction();
	        HttpServletResponse response = ServletActionContext.getResponse();
	 
	                response.setContentType(action.getMyContentType());
	        response.setContentLength(action.getMyContentLength());
	 
	        response.getOutputStream().write(action.getMyImageInBytes());
	        response.getOutputStream().flush();
	    }
}
